#include "GetAddress.h"

using namespace std;


char* GetAddress(char* host){

  char address[100] = "";
  int length = 100;
  void* point;
  struct addrinfo hints;
  bzero(&hints, sizeof(hints));
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_family = AF_INET;

  struct addrinfo* result;
  struct addrinfo* res;

  if(getaddrinfo(host, NULL, NULL, &result)!= 0){
    cout<< "Could not find address" << endl;
  }
  else{
    for(res = result; res != NULL; res = res->ai_next){
      //inet_ntop(res->ai_family, res->ai_addr->sa_data, address, length);
      point = &((struct sockaddr_in*) res->ai_addr)->sin_addr;
      inet_ntop(res->ai_family, point, address, length);
      cout<< address << endl;
    }
  }


}

